home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / Hello / Source / Sources / HelloMain.cc next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  2.4 KB  |  104 lines

  1. /* PedestalDemoMain.cc */
  2.  
  3. #include "Ped1ObjectDeity.hh"
  4. #include "Ped1AppProcess.hh"
  5. #include "PedApplication.hh"
  6.  
  7. // For HelloAgent
  8. #include "PedAgent.hh"
  9. #include "PedWindow.hh"
  10. #include "PedPaneSubView.hh"
  11. #include "PedViewScrollerSimple.hh"
  12. #include "PedViewScroll.hh"
  13. #include "PedPaneIconAnimated.hh"
  14. #include "PedScrollbar.hh"
  15.  
  16.  
  17. //    HelloAgent
  18. //    ----------
  19.  
  20. class HelloAgent : public PedAgent {
  21. public:
  22.     HelloAgent(PedTask *inParent) : PedAgent(inParent) {}
  23.     virtual ~HelloAgent() {}
  24.     
  25.     virtual void InitWindow();
  26. };
  27.  
  28.  
  29. void
  30. HelloAgent::InitWindow()
  31. {
  32.     if (!mWindow) {
  33.         mWindow = new PedWindow(this);
  34.         
  35.         //Rect rect = {18, 0, 18+2*4+11*25+16, 2*4+6*80+16};
  36.         Rect rect = {18, 0, 18+128+15, 128+15};
  37.         short mbarHeight = ::GetMBarHeight();
  38.         short vMargin = (qd.screenBits.bounds.bottom - rect.bottom) - mbarHeight;
  39.         short hMargin = (qd.screenBits.bounds.right - rect.right);
  40.         ::OffsetRect(&rect, hMargin / 2, mbarHeight + vMargin / 3);
  41.         
  42.         // Set the bounds before creating the pane, because things aren't
  43.         // perfect yet and the pane will be sized to the old bounds.
  44.         mWindow->SetBounds(rect);
  45.         mWindow->SetTitle("\pHello");
  46.         
  47.         PedPaneSubView *top = new PedPaneSubView(*mWindow);
  48.         mWindow->SetPane(top);
  49.         top->release();
  50.         
  51.         PedViewScrollerSimple *scroller = new PedViewScrollerSimple(*top);
  52.         top->SetSubView(scroller);
  53.         scroller->release();
  54.         scroller->SetScrollbarPresence(kPedScrollVertical + kPedScrollHorizontal, true);
  55.         
  56.         PedPaneIconAnimated *iconpane = new PedPaneIconAnimated(*scroller->ScrollView());
  57.         scroller->SetPane(iconpane);
  58.         iconpane->release();
  59.         
  60.         // Remember the rule -- every new/retain must be balanced!
  61.         // (We retain and store the window when it calls PedAgent::SetWindow().)
  62.         mWindow->release();
  63.     }
  64. }
  65.  
  66. //    HelloClassAgent
  67. //    ---------------
  68.  
  69. class HelloClassAgent : public PedClassAgent {
  70. public:
  71.     HelloClassAgent(PedTask *inPrimaryTask) : PedClassAgent(inPrimaryTask) {}
  72.     virtual PedAgent *MakeAgent();
  73.     //PedAgent *MakeInstance() {return MakeAgent();}
  74. };
  75.  
  76. PedAgent *
  77. HelloClassAgent::MakeAgent()
  78. {
  79.     HelloAgent *agent = new HelloAgent(mPrimaryTask);
  80.     agent->autorelease();
  81.     
  82.     return agent;
  83. }
  84.  
  85. //    main
  86. //    ----
  87.  
  88. int main(void)
  89. {
  90.     Ped1AppProcess aProcess;
  91.     
  92.     aProcess.Init();
  93.     
  94.     PedApplication app;
  95.     HelloClassAgent agentClass(&app);
  96.     //gOD->RegisterClass('Agnt', agentClass);
  97.     //gOD->RegisterFabricator('Agnt', &MakeAgent);
  98.     gOD->RegisterAgentClass(&agentClass);
  99.     
  100.     aProcess.Call(app);
  101.     
  102.     return 0;
  103. }
  104.